#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;

int n, k, S, ans;
vector<int>p[N];
bool flag;
void dfs(int x, int fa, int Len, int res) {
	if(!flag) return;
	if(S & (1 << (x - 1))) res++;
	if(Len == k) {
		if(res != 1) flag = 0;
		return;
	}
	for(auto y : p[x]) {
		if(y == fa) continue;
		dfs(y, x, Len + 1, res);
	}
}

signed main() {
	freopen("life.in", "r", stdin);
	freopen("life.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> n >> k;
	if(n > 18) {
		cout << "YES" << endl;
		cout << k;
		return 0;
	}
	for(int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		p[u].push_back(v);
		p[v].push_back(u);
	}
	for(S = 0; S < (1 << n); S++) {
		flag = 1;
		for(int i = 1; i <= n; i++) dfs(i, 0, 1, 0);
		if(flag) ans++;
	}
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
	cout << ans;
	return 0;
}

